package cn.wolfcode.shop.cloud.msg;


import cn.wolfcode.shop.cloud.CodeMsg;
import org.springframework.validation.BindException;

import java.text.MessageFormat;


public class MemberCodeMsg extends CodeMsg {
    public static final MemberCodeMsg LOGIN_OPT = new MemberCodeMsg(50001,"违法的操作");
    public static final MemberCodeMsg LOGIN_FAIL = new MemberCodeMsg(50002,"账号或者密码不匹配");
    public static final MemberCodeMsg ARGUMENTS_OPT = new MemberCodeMsg(50003,"参数异常信息:{0}");
    public static final MemberCodeMsg USER_AND_PASSWORD_NOT_NULL = new MemberCodeMsg(50004,"账号和密码不能为空");
    public static final MemberCodeMsg USER_NOT_EXISTS = new MemberCodeMsg(50005,"该用户不存在");


    public MemberCodeMsg filterArg(String ...args){
        MemberCodeMsg memberCodeMsg = new MemberCodeMsg();
        memberCodeMsg.setCode(this.getCode());
        memberCodeMsg.setMsg(MessageFormat.format(this.getMsg(),args));
        return memberCodeMsg;
    }

    @Override
    public String toString() {
        return "code:"+this.getCode()+"======msg:"+this.getMsg();
    }


    public MemberCodeMsg() {
    }

    public MemberCodeMsg(int code, String msg) {
        super(code, msg);
    }

    /*public static void main(String[] args) {
        String str = "aaa,{0}";
        String pass = MessageFormat.format(str,"罗罗");
        System.out.println(pass);
    }*/
}
